<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/4/11
  Time: 9:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
  </head>
  <script src="./js/jquery-3.4.1.min.js" type="application/javascript"></script>
  <script type="application/javascript">
    $(function () {
          $("#login").click(function () {
                let name = $("#name").val();
                let password = $("#password").val();
                if(name==null){
                    alert("用户名不能为空");
                    return;
                }
                if(password==null){
                  alert("密码不能为空");
                  return;
                }

                $.ajax({
                    url:"/user",
                    data:{
                      type:"toLogin",
                      name:name,
                      password:password
                    },
                    type:"GET",
                    dataType:"json",
                    success:function (data) {
                        if(data.status==200){
                          alert(data.msg)
                          location.href="/user?type=userIndex&id="+data.data.id;
                        }
                    }


                })

          })

    })


  </script>
  <body>
      <form action="javascript:void(0)">
        <label>用户名</label>
          <input type="text" id="name" name="name" value=""><br>
        <label>密码</label>
          <input type="password" id="password" name="password" value=""><br>
      </form>
        <button id="login">登录</button>
  </body>
</html>
